<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="person_info" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="contactsUSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>更新</el-button>
          <el-button @click="gotoPage('CB313B6ACCCF4CB3B8BC9C033015C126?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 添加联系人 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-radio-group v-model="person_info.contact_oneorclient">
                  <el-radio-button label="个人联系人">个人联系人</el-radio-button>
                  <el-radio-button label="客户联系人">客户联系人</el-radio-button>
                </el-radio-group>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="相关的记录" prop="">
                  <el-link @click="gotoPage('F6EEF5D6394C4994B84028AB600FAFDE?'+vueparams+'')" type='primary'>{{person_info['']}}</el-link>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="联系人类别" prop="contact_type">
                  <el-select style='width:100%' v-model="person_info.contact_type">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in clienttype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="联系人类型" prop="contact_mode">
                  <el-select style='width:100%' v-model="person_info.contact_mode">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in clientsort" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-input v-model="person_info.visit_type" />
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="姓名" prop="person_name">
                  <el-input v-model="person_info.person_name" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="英文名" prop="english_name">
                  <el-input v-model="person_info.english_name" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="性别" prop="person_sex">
                  <el-radio-group v-model="person_info.person_sex">
                    <el-radio-button label="男">男</el-radio-button>
                    <el-radio-button label="女">女</el-radio-button>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="附加名称" prop="annex_name">
                  <el-input v-model="person_info.annex_name" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="昵称" prop="nick_name">
                  <el-input v-model="person_info.nick_name" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="出生日期" prop="person_birthday">
                  <el-date-picker v-model="person_info.person_birthday" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="公司" prop="firm">
                  <el-input v-model="person_info.firm" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="岗位" prop="person_station">
                  <el-select style='width:100%' v-model="person_info.person_station">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in station_info" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="角色" prop="">
                  <el-input v-model="empty" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 电话号码 </span>
          </div>
          <el-table :data="phones_info">
            <el-table-column label="电话" prop="">
            </el-table-column>
            <el-table-column label="类型" prop="phones_type" 类型>
              <template slot-scope="scope">
                <el-select style='width:100%' v-model="scope.row.phones_type">
                  <el-option label="－－无－－" value='' />
                  <el-option v-for="dict in phonetype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="号码" prop="phones_number">
              <template slot-scope="scope">
                <el-input v-model="scope.row.phones_number" />
              </template>
            </el-table-column>
            <el-table-column label="分机" prop="phones_extension">
              <template slot-scope="scope">
                <el-input v-model="scope.row.phones_extension" />
              </template>
            </el-table-column>
            <el-table-column label="主要的" prop="">
              <template slot-scope="scope">
                <el-radio-group v-model="empty">
                  <el-radio-button label=""></el-radio-button>
                </el-radio-group>
              </template>
            </el-table-column>
            <el-table-column label="电话号码谢绝" prop="">
              <template slot-scope="scope">
                <el-checkbox v-model="empty" :checked="empty==1? true:false" label="谢绝来电">谢绝来电</el-checkbox>
                <el-checkbox v-model="empty" :checked="empty==1? true:false" label="谢绝传真">谢绝传真</el-checkbox>
              </template>
            </el-table-column>
          </el-table>
          <div class="form-unit">
            <span class="mvc-title-left"> 电子邮件地址 </span>
          </div>
          <el-table :data="email_info">
            <el-table-column label="电话" prop="">
            </el-table-column>
            <el-table-column label="类型" prop="email_type" 类型>
              <template slot-scope="scope">
                <el-select style='width:100%' v-model="scope.row.email_type">
                  <el-option label="－－无－－" value='' />
                  <el-option v-for="dict in emailtype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="号码" prop="email_address">
              <template slot-scope="scope">
                <el-input v-model="scope.row.email_address" />
              </template>
            </el-table-column>
            <el-table-column label="主要的" prop="">
              <template slot-scope="scope">
                <el-radio-group v-model="empty">
                  <el-radio-button label=""></el-radio-button>
                </el-radio-group>
              </template>
            </el-table-column>
            <el-table-column label="邮件谢绝" prop="">
              <template slot-scope="scope">
                <el-radio-group v-model="empty">
                  <el-radio-button label="是">是</el-radio-button>
                  <el-radio-button label="否">否</el-radio-button>
                </el-radio-group>
              </template>
            </el-table-column>
          </el-table>
          <div class="form-unit">
            <span class="mvc-title-left"> 即时通讯地址 </span>
          </div>
          <el-table :data="contact_ifno">
            <el-table-column label="即时通讯地址" prop="">
            </el-table-column>
            <el-table-column label="类型" prop="contact_pritype" 类型>
              <template slot-scope="scope">
                <el-select style='width:100%' v-model="scope.row.contact_pritype">
                  <el-option label="－－无－－" value='' />
                  <el-option v-for="dict in momentcon" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="类型2" prop="contact_lestype" 类型2>
              <template slot-scope="scope">
                <el-select style='width:100%' v-model="scope.row.contact_lestype">
                  <el-option label="－－无－－" value='' />
                  <el-option v-for="dict in momentconano" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="号码" prop="contact_number">
              <template slot-scope="scope">
                <el-input v-model="scope.row.contact_number" />
              </template>
            </el-table-column>
            <el-table-column label="主要的" prop="">
              <template slot-scope="scope">
                <el-radio-group v-model="empty">
                  <el-radio-button label=""></el-radio-button>
                </el-radio-group>
              </template>
            </el-table-column>
            <el-table-column label="有无IM请求" prop="">
              <template slot-scope="scope">
                <el-radio-group v-model="empty">
                  <el-radio-button label="有">有</el-radio-button>
                  <el-radio-button label="无">无</el-radio-button>
                </el-radio-group>
              </template>
            </el-table-column>
          </el-table>
          <div class="form-unit">
            <span class="mvc-title-left"> 文本消息地址 </span>
          </div>
          <el-table :data="text_info">
            <el-table-column label="地址" prop="">
            </el-table-column>
            <el-table-column label="类型" prop="text_type" 类型>
              <template slot-scope="scope">
                <el-select style='width:100%' v-model="scope.row.text_type">
                  <el-option label="－－无－－" value='' />
                  <el-option v-for="dict in text" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="地址栏" prop="text_address">
              <template slot-scope="scope">
                <el-input v-model="scope.row.text_address" />
              </template>
            </el-table-column>
            <el-table-column label="主要的" prop="">
              <template slot-scope="scope">
                <el-radio-group v-model="empty">
                  <el-radio-button label=""></el-radio-button>
                </el-radio-group>
              </template>
            </el-table-column>
            <el-table-column label="" prop="">
              <template slot-scope="scope">
                <el-radio-group v-model="empty">
                  <el-radio-button label="是">是</el-radio-button>
                  <el-radio-button label="否">否</el-radio-button>
                </el-radio-group>
              </template>
            </el-table-column>
          </el-table>
          <div class="form-unit">
            <span class="mvc-title-left"> 地址 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="类型" prop="address_type">
                  <el-select style='width:100%' v-model="address_info.address_type">
                    <el-option label="主要的" value="主要的" />
                    <el-option label="辅助的" value="辅助的" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="地址行" prop="address_info">
                  <el-input type="textarea" v-model="address_info.address_info" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="城市" prop="address_city">
                  <el-input v-model="address_info.address_city" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="省" prop="address_province">
                  <el-select style='width:100%' v-model="address_info.address_province">
                    <el-option label="河北省" value="河北省" />
                    <el-option label="河南省" value="河南省" />
                    <el-option label="陕西省" value="陕西省" />
                    <el-option label="山西省" value="山西省" />
                    <el-option label="山东省" value="山东省" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="邮政编码" prop="address_postcode">
                  <el-input v-model="address_info.address_postcode" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="国家" prop="address_nation">
                  <el-select style='width:100%' v-model="address_info.address_nation">
                    <el-option label="中国" value="中国" />
                    <el-option label="美国" value="美国" />
                    <el-option label="英国" value="英国" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="纬度" prop="address_latitude">
                  <el-input v-model="address_info.address_latitude" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="经度" prop="address_longitude">
                  <el-input v-model="address_info.address_longitude" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 额外明细 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="remark">
                  <el-input type="textarea" v-model="person_info.remark" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="contactsUSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>更新</el-button>
          <el-button @click="gotoPage('CB313B6ACCCF4CB3B8BC9C033015C126?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'客户联系人'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'ContactsU',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        person_info: {
          contact_oneorclient: null,
          contact_type: null,
          contact_mode: null,
          visit_type: null,
          person_name: null,
          english_name: null,
          person_sex: null,
          annex_name: null,
          nick_name: null,
          person_birthday: null,
          firm: null,
          person_station: null,
        },
        phones_info: [],
        email_info: [],
        contact_ifno: [],
        text_info: [],
        address_info: {
          address_type: null,
          address_info: null,
          address_city: null,
          address_province: null,
          address_postcode: null,
          address_nation: null,
          address_latitude: null,
          address_longitude: null,
          remark: null,
        },
        clienttype: [],
        clientsort: [],
        station_info: [],
        phonetype: [],
        emailtype: [],
        momentcon: [],
        momentconano: [],
        text: [],
        loading: false,
        Container: null,
        rules: {
          person_name: [{
            required: true,
            message: "姓名不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "客户联系人"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/ContactsU/contactsU?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      contactsUSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/supplychainmana/ContactsU/contactsUSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.$router.replace("/redirect" + this.$route.fullPath);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
